package top.glkj.hms.utils;

import top.glkj.hms.exception.DefineException;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author : xgl
 * @version : 0.0.1
 * @date :2020/12/21 20:55
 */
public final class DateUtils {

    public static Date format(String... par) throws DefineException {
        if (par.length > StaticValue.TWO) {
            throw new DefineException("par is maxSize two but this par is" +
                    par.length + ",so you giv me par one or two");
        }
        SimpleDateFormat format = new SimpleDateFormat();
        try {
            return format.parse(par[0]);
        } catch (ParseException e) {
            throw new DefineException(e);
        }
    }

    public static void main(String[] args) throws DefineException {
        System.out.println(format("2030/12/17 22:10:11"));
    }
}
